import React,{useEffect,useState} from 'react'
import Item from './Item'
import PubSub from 'pubsub-js'
export default function List(){
    const [searchList, setSearchList] = useState([]);
    useEffect(()=>{
        PubSub.subscribe('github',(_,data)=>{
            setSearchList(data.data.items)   
        })
    },[])
    return (
        <div >
            {
                searchList.map(item => {
                    return <Item key={item.id} {...item} />
                  })
            }
        </div>
    )
}
